/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package py.com.peluq.model.entity;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.CascadeType;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Diego_M
 */
@Entity
@Table(name = "ctas_titular", catalog = "peludb", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "CtasTitular.findAll", query = "SELECT c FROM CtasTitular c"),
    @NamedQuery(name = "CtasTitular.findByIdctasTitular", query = "SELECT c FROM CtasTitular c WHERE c.ctasTitularPK.idctasTitular = :idctasTitular"),
    @NamedQuery(name = "CtasTitular.findByIdctasCorrientes", query = "SELECT c FROM CtasTitular c WHERE c.ctasTitularPK.idctasCorrientes = :idctasCorrientes")})
public class CtasTitular implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected CtasTitularPK ctasTitularPK;
    @JoinColumn(name = "idtitulares", referencedColumnName = "idtitulares", nullable = false)
    @ManyToOne(optional = false)
    private Titulares idtitulares;
    @JoinColumn(name = "idctas_corrientes", referencedColumnName = "idctas_corrientes", nullable = false, insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private CtasCorrientes ctasCorrientes;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "ctasTitular")
    private Collection<ConciBanco> conciBancoCollection;

    public CtasTitular() {
    }

    public CtasTitular(CtasTitularPK ctasTitularPK) {
        this.ctasTitularPK = ctasTitularPK;
    }

    public CtasTitular(int idctasTitular, int idctasCorrientes) {
        this.ctasTitularPK = new CtasTitularPK(idctasTitular, idctasCorrientes);
    }

    public CtasTitularPK getCtasTitularPK() {
        return ctasTitularPK;
    }

    public void setCtasTitularPK(CtasTitularPK ctasTitularPK) {
        this.ctasTitularPK = ctasTitularPK;
    }

    public Titulares getIdtitulares() {
        return idtitulares;
    }

    public void setIdtitulares(Titulares idtitulares) {
        this.idtitulares = idtitulares;
    }

    public CtasCorrientes getCtasCorrientes() {
        return ctasCorrientes;
    }

    public void setCtasCorrientes(CtasCorrientes ctasCorrientes) {
        this.ctasCorrientes = ctasCorrientes;
    }

    @XmlTransient
    public Collection<ConciBanco> getConciBancoCollection() {
        return conciBancoCollection;
    }

    public void setConciBancoCollection(Collection<ConciBanco> conciBancoCollection) {
        this.conciBancoCollection = conciBancoCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (ctasTitularPK != null ? ctasTitularPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof CtasTitular)) {
            return false;
        }
        CtasTitular other = (CtasTitular) object;
        if ((this.ctasTitularPK == null && other.ctasTitularPK != null) || (this.ctasTitularPK != null && !this.ctasTitularPK.equals(other.ctasTitularPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "py.com.peluq.model.entity.CtasTitular[ ctasTitularPK=" + ctasTitularPK + " ]";
    }
    
}
